
package com.example.liang.basamovie.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.liang.basamovie.R;
import android.content.Intent;
import android.widget.ImageView;
import com.example.liang.basamovie.activity.SeleteFilmActivity;
import com.example.liang.basamovie.adapter.FindAdapter;
import com.example.liang.basamovie.fragment.FindChildFragment.ConcernFragment;
import com.example.liang.basamovie.fragment.FindChildFragment.MustNewFragment;

import java.util.ArrayList;
import java.util.List;


/**
 * 发现的碎片
 */

public class FindFragment extends Fragment {
   ViewPager viewPager;
    TabLayout tabLayout;
    ImageView find_seleteFilm;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_find, null);
        viewPager= (ViewPager) view.findViewById(R.id.viewpager);
        tabLayout= (TabLayout) view.findViewById(R.id.tablelaout);
        find_seleteFilm= (ImageView) view.findViewById(R.id.find_seleteFilm);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
        List<Fragment> list=new ArrayList<>();
        list.add(new MustNewFragment());
        list.add(new ConcernFragment());
        FindAdapter adapter = new FindAdapter(getChildFragmentManager(), list);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        find_seleteFilm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(getContext(),"点击搜索",Toast.LENGTH_LONG).show();
                Intent intent=new Intent(getActivity(),SeleteFilmActivity.class);
                startActivity(intent);

            }
        });

    }

}

